﻿namespace GoodAdmin.Web.Core;

/// <summary>
/// 认证服务
/// </summary>
[ApiDescriptionSettings("System", Tag = "认证服务")]
[Route("/system/auth")]
public class AuthController:IDynamicApiController
{
    private readonly IAuthService _authService;

    public AuthController(IAuthService authService)
	{
        _authService = authService;
    }

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("login")]
    [DisplayName("登录")]
    [AllowAnonymous]
    public async Task<LoginOutput> Login(LoginInput input)
    {
       return await _authService.Login(input);
    }

    /// <summary>
    /// 退出
    /// </summary>
    /// <returns></returns>
    [HttpGet("loginOut")]
    [DisplayName("退出")]
    public void LoginOut(string token)
    {
        _authService.LoginOut(token);
    }

    /// <summary>
    /// 获取验证码
    /// </summary>
    /// <returns></returns>
    [HttpGet("GetCaptcha")]
    [DisplayName("获取验证码")]
    [AllowAnonymous]
    public dynamic GetCaptcha()
    {
        return _authService.GetCaptcha();
    }

    /// <summary>
    /// 获取登录时配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("GetConfig")]
    [DisplayName("获取登录时配置")]
    [AllowAnonymous]
    public async Task<dynamic> GetLoginConfig()
    {
        return await _authService.GetLoginConfig();
    }
}